using System;
using System.Collections;
using System.Collections.Generic;
using MotionFramework.Console;
using MotionFramework.Resource;
using UnityEngine;

/// <summary>
/// UI管理器
/// </summary>
namespace MotionFramework.UIKit
{
    public class WindowManager : ModuleSingleton<WindowManager>, IModule, IWindowOperation
    {
        void IModule.OnCreate(object createParam)
        {
            // 检测依赖模块
			if (MotionEngine.Contains(typeof(ResourceManager)) == false)
				throw new Exception($"{nameof(WindowManager)} depends on {nameof(ResourceManager)}");
        }

        void IModule.OnDestroy()
        {
			DestroySingleton();
        }

        void IModule.OnGUI()
        {
            //var count = UIManager.GetInstance().GetDicALLUIWindowCount();
            //ConsoleGUI.Lable($"[{nameof(WindowManager)}] Forms total count : {count}");
        }

        void IModule.OnUpdate()
        {
        }

        public virtual void ShowUIWindow(string name)
        {
            UIManager.GetInstance().ShowUIWindow(name);
        }

        public virtual void ShowUIWindow<T>() where T : UIWindow
        {
            var name = typeof(T).Name;
            UIManager.GetInstance().ShowUIWindow(name);
        }

        public virtual void CloseUIWindow(string name)
        {
            UIManager.GetInstance().CloseUIWindow(name);
        }

        public virtual void CloseUIWindow<T>() where T : UIWindow
        {
            var name = typeof(T).Name;
            UIManager.GetInstance().CloseUIWindow(name);
        }

        public virtual void CloseAllUIWindow()
        {
            UIManager.GetInstance().CloseAllUIWindow();
        }
    }
}
